import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CommissionListVO, CommissionListForm, CommissionListQuery } from '@/api/commission/commissionList/types';

/**
 * 查询佣金清单列表
 * @param query
 * @returns {*}
 */

export const listCommissionList = (query?: CommissionListQuery): AxiosPromise<CommissionListVO[]> => {
  return request({
    url: '/commission/commissionList/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询佣金清单详细
 * @param id
 */
export const getCommissionList = (id: string | number): AxiosPromise<CommissionListVO> => {
  return request({
    url: '/commission/commissionList/' + id,
    method: 'get'
  });
};

/**
 * 新增佣金清单
 * @param data
 */
export const addCommissionList = (data: CommissionListForm) => {
  return request({
    url: '/commission/commissionList',
    method: 'post',
    data: data
  });
};

/**
 * 修改佣金清单
 * @param data
 */
export const updateCommissionList = (data: CommissionListForm) => {
  return request({
    url: '/commission/commissionList',
    method: 'put',
    data: data
  });
};

/**
 * 删除佣金清单
 * @param id
 */
export const delCommissionList = (id: string | number | Array<string | number>) => {
  return request({
    url: '/commission/commissionList/' + id,
    method: 'delete'
  });
};

/**
 * 导出佣金清单
 * 
 */
export const exportCommissionList = (query: any) => {
  return request({
    url: '/commission/commissionList/export',
    method: 'post',
    params: query,
  });
};

/**
 * 下载完成取消websocket请求
 */
export const closeDownload = () => {
  return request({
    url: '/commission/commissionList/closeDownload',
    method: 'get'
  });
};

